from django.urls import re_path
from rest_framework_jwt.views import obtain_jwt_token
from .views import statistical, user, skus, orders, sku, goods, permission

urlpatterns = [
    # 管理员登陆
    re_path(r'^authorizations/$', obtain_jwt_token),
    # 用户总量统计
    re_path(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 日活跃用户统计
    re_path(r'^statistical/day_active/$', statistical.UserDailyActiveCountView.as_view()),
    # 日下单用户量统计
    re_path(r'^statistical/day_orders/$', statistical.UserDailyOrderCountView.as_view()),
    # 日注册量统计
    re_path(r'^statistical/day_increment/$', statistical.UserDailyIncrementCountView.as_view()),
    # 月增用户统计
    re_path(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 实现日分类商品访问量
    re_path(r'^statistical/goods_day_views/$', skus.SKUDailyIncrementCountView.as_view()),
    # 用户管理
    re_path(r'^users/$', user.UserListView.as_view()),
    # 统计分类商品访问量
    re_path(r'^detail/visit/(?P<category_id>\d+)/$', skus.SKUCountView.as_view()),

    # 获取SKU三级分类信息
    re_path(r'^skus/categories/$', skus.SKUCategoriesView.as_view()),
    # sku列表
    re_path(r'^skus/simple/$', skus.SKUView.as_view()),

    # 获取SPU表名称数据
    re_path(r'^goods/simple/$', skus.GoodsSimpleView.as_view()),
    # 获取SPU商品规格信息
    re_path(r'^goods/(?P<pk>\d+)/specs/$', skus.GoodsSpecView.as_view()),
    # 获取品牌信息
    re_path(r'^goods/brands/simple/$', goods.BrandsSimpleView.as_view()),
    # 获取一级分类信息
    re_path(r'^goods/channel/categories/$', goods.ChannelCategoriesView.as_view()),
    # 获取二级和三级分类
    re_path(r'^goods/channel/categories/(?P<pk>\d+)/$', goods.ChannelCategoriesView.as_view()),
    # 获取商品规格选项
    re_path(r'^goods/specs/simple/$', goods.GoodsSpecsSimpleView.as_view()),

    # 获取订单表数据
    re_path(r'^orders/$', orders.OrderListView.as_view()),
    # 获取订单表详情数据
    re_path(r'^orders/(?P<pk>\d+)/$', orders.OrderInfoView.as_view()),
    # 更新订单表状态数据
    re_path(r'^orders/(?P<order_id>\d+)/status/$', orders.OrderStateView.as_view()),
    # 获取权限类型列表数据
    re_path(r'^permission/content_types/$', permission.PermissionContentTypesView.as_view()),
    # 获取权限表数据
    re_path(r'^permission/simple/$', permission.PermissionSimpleView.as_view()),
    # 获取分组表数据
    re_path(r'^permission/groups/simple/$', permission.PermissionGroupsSimpleView.as_view()),


]


from rest_framework.routers import DefaultRouter

router = DefaultRouter()

# 图片管理
router.register(r'skus/images', skus.ImageView, basename='image')

urlpatterns += router.urls

# SKU管理
router.register(r'skus', sku.SKUModelViewSet, basename='skus')

urlpatterns += router.urls

# 规格表管理
router.register(r'goods/specs', goods.SPUSpecsModelViewSet, basename='specs')

urlpatterns += router.urls

# 品牌表管理
router.register(r'goods/brands', goods.GoodsBrandsModelViewSet, basename='options')

urlpatterns += router.urls

# 商品管理
router.register(r'goods', goods.SPUModelViewSet, basename='goods')

urlpatterns += router.urls

# 规格选项表管理
router.register(r'specs/options', goods.SpecsOptionsModelViewSet, basename='options')

urlpatterns += router.urls

# 权限表管理
router.register(r'permission/perms', permission.PermissionPermsModelViewSet, basename='perms')

urlpatterns += router.urls

# 分组表管理
router.register(r'permission/groups', permission.PermissionGroupsModelViewSet, basename='groups')

urlpatterns += router.urls

# 管理员表管理
router.register(r'permission/admins', permission.PermissionAdminsModelViewSet, basename='admins')

urlpatterns += router.urls

